import axios from 'axios';
// import { Notification } from 'element-ui';
// instance是axios的实例对象
const instance = axios.create({
    baseURL: 'http://localhost:8088/',
    timeout: 3000,
    headers: {'X-Custom-Header': 'foobar'}
});

instance.interceptors.request.use(config=>{
    return config;
},error => {
    return Promise.reject(error);
});

instance.interceptors.response.use(resp=> {
    let {status,message,data} = resp.data;
    if (status == 20000) {
        return data;
    }else {
        Notification.error(message);
        //留作演示
        return Promise.reject(false);
    }
}, error=> {
    return Promise.reject(error);
});

export default instance;